﻿using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using Csla.Data;

namespace buildingLib.fee
{
    [Serializable()]
    public class paytypes : NameValueListBase<Guid,string>
    {
        public static paytypes GetPayTypes()
        {
            return DataPortal.Fetch<paytypes>();
        }

        private void DataPortal_Fetch()
        {
            Database db = SQLDatabase.GetDatabase();
            DbCommand dbcom = db.GetSqlStringCommand("select [ID],[name] from paytype order by len([name]) asc");
            using(SafeDataReader dr = new SafeDataReader(db.ExecuteReader(dbcom)))
            {
                this.IsReadOnly = false;
                while (dr.Read())
                {                   
                        this.Add(new NameValuePair(dr.GetGuid(0),dr.GetString(1)));
                }
                this.IsReadOnly = true;
            }
        }
    }
}
